@extends("public.main")
@section("content")
    <div style="margin-left:200px;">
        <nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 学校管理 <span class="c-gray en">&gt;</span> 学院列表</nav>
        <div class="page-container">
            <div class="cl pd-5 bg-1 bk-gray "> <span class="l">
                    <a class="btn btn-primary radius"  href="/admin/room/add/{{$id}}"><i class="Hui-iconfont">&#xe600;</i> 添加宿舍</a></span>
            </div>
            <div class="mt-20">
                <table class="table table-border table-bordered table-bg table-hover table-sort">
                    <thead>
                    <tr class="text-c">
                        <th width="40">ID</th>
                        <th width="100">学校</th>
                        <th width="100">宿舍楼</th>
                        <th width="100">类别</th>
                        <th width="100">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    @if(!empty($data['data']))
                        @foreach($data['data'] as $k => $v)
                            <tr class="text-c va-m">
                                <td>{{ $v['id'] }}</td>
                                <td>{{ $v['name'] }}</td>
                                <td>{{ $v['number_name'] }}</td>
                                <td>@if($v['type'] == 0) 学生宿舍 @else <span style="color: red"> 教学楼 </span> @endif</td>
                                <td class="td-manage"><a style="text-decoration:none" class="ml-5" href="/admin/room/edit/{{$v['id']}}" title="编辑"><i class="Hui-iconfont">&#xe6df;</i></a><a style="text-decoration:none" class="ml-5"  onclick="deleteCategory(this,{{$v['id'] }})" title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a></td>
                            </tr>
                        @endforeach
                    @else
                        <tr class="text-c va-m">暂无数据</tr>
                    @endif
                    </tbody>
                </table>
                <div id="pagelist" style="float:right;margin-top:10px">
                    {!! $data['data']->appends(['type' => $data['type']])->render() !!}
                </div>
            </div>
        </div>
    </div>
@endsection
<script>
    /*产品-删除*/
    function deleteCategory(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            $.ajax({
                type: 'POST',
                url: '/admin/category/del_category',
                data:{id:id},
                dataType: 'json',
                success: function(data){
                    if(data.status == 200) {
                        $(obj).parents("tr").remove();
                        layer.msg('已删除!', {icon: 1, time: 1000});
                    } else {
                        layer.msg('删除失败!', {icon: 1, time: 1000});
                    }
                },
                error:function(data) {
                    console.log(data.msg);
                },
            });
        });
    }

</script>
